<template>
  <el-row class="tableWrap">
    <el-row class="title">
      <el-row class="partTitle">{{ $store.getters.getLocation }}{{ title }}</el-row>
    </el-row>
    <el-row type="flex" class="tableHeaderWrap">
      <div v-for="header in headerList" class="tableHeader">{{ header }}</div>
    </el-row>
    <div style="display: flex;flex-direction: column;height:calc(100% - 76px)">
      <el-row
        v-for="(row, index) in dataList"
        :key="index" type="flex"
        :class="index%2 !== 0 ? 'dark' : ''"
        class="tableBody"
        @click.native="selectProvince(row[row.length - 1])"
      >
        <div v-if="num < row.length - 1" v-for="(item, num) in row" class="tableName">{{ item }}</div>
      </el-row>
    </div>
  </el-row>
</template>

<script>
  import MapData from '@/config'
  export default {
    name: "CommonTale",
    props: {
      dataList: {
        type: Array,
        default: ()=>[]
      },
      headerList: {
        type: Array,
        default: ()=>[]
      },
      title: {
        type: String,
        default: ''
      }
    },
    data() {
      return {
        provinceList: MapData.originProvinceList
      }
    },
    methods: {
      selectProvince(code) {
        if (this.provinceList.some(item => item.code === code)) {
          this.$bus.$emit('locationSelect', code)
        }
      }
    }
  }
</script>

<style scoped>
.tableWrap{
  border-radius: 5px;
  background: rgba(24,66,107,0.59);
  box-shadow: 0px 1px 4px 0px rgba(20,46,110,0.1);
  height: 100%;
}
.title{
  height: 40px;
  color: #FFFFFF;
  font-size: 20px;
  line-height: 40px;
  text-align: left;
  letter-spacing: 4px;
}
.tableHeaderWrap{
  background: #003F87;
  border-top: 1px solid rgba(64,169,255,0.5);
  border-bottom: 1px solid rgba(64,169,255,0.5);
  /*margin: 20px 0 10px 0;*/
  padding: 2px 30px 0 0;
}
.tableHeader{
  flex: 1;
  color: #FFFFFF;
  font-family: Microsoft Tai Le;
  text-shadow: 0 0 0.3rem #00d8ff;
  font-weight: 400;
  font-size: 16px;
  line-height: 36px;
  height: 36px;
  text-align: center;
}
.tableName{
  display: flex;
  flex: 1;
  justify-content: center;
  font-family: Microsoft Sans Serif;
  font-weight: 500;
  font-size: 14px;
  text-align: center;
  vertical-align: middle;
}
.tableBody{
  flex: 1;
  align-items: center;
  padding: 0px 30px 0 0;
  color: #ffffff;
  max-height: 40px;
  cursor: pointer;
  /*line-height: 50px;*/
}
.tableBody:hover{
  background: linear-gradient(#329ed2, #5b5bf6);
  color: #ffffff;
}
.chinaButton{
  padding: 0;
  font-size: 16px;
  height: 16px;
  height: 16px;
}
.partTitle{
  background: rgba(71, 90, 192, 0.96);
  text-align: center;
}
.dark{
  background: rgba(24,66,107,0.7)
}
.dark:hover{
  background: linear-gradient(#329ed2,#5b5bf6);
  color: #ffffff;
}
</style>
